#ifndef __ATL_KRNL_VMM__
#define __ATL_KRNL_VMM__
#include <cstdint.h>
#include "pmm.h"
#define PAGE_PRESENT			1 << 0
#define PAGE_WRITABLE			1 << 1
#define PAGE_USERMODE			1 << 2
#define PAGE_WRITETHROUGH		1 << 3
#define PAGE_NOCACHE			1 << 4
#define PAGE_ACCESS				1 << 5
#define PAGE_DIRTY				1 << 6
#define PAGE_SIZE				1 << 7
#define PAGE_GLOBAL				1 << 8

#define PAGE_ADDRESS_MASK		0xFFFFF000
#define PAGE_TAG_MASK			7 << 9
#define PAGE_FLAGS_MASK			0x67
#define PAGET_FLAGS_MASK		0x1FF

#define PAGE_TAG_OFFSET			0x9

#define VPTR_PAGE_OFFSET		12
#define VPTR_DIRECTORY_OFFSET	22

#define VPTR_PAGE_MASK			0x3FF
#define VPTR_DIRECTORY_MASK		0x3FF

#define PAGE_DIRECTORY_SIZE		1024
#define PAGE_TABLE_SIZE			1024
#define PAGE_TABLE_VSIZE		0x400000
typedef uint32_t pt_entry;
typedef uint32_t pd_entry;
typedef uint32_t virtual_addr;

typedef struct ptable_s {
	pt_entry pages[PAGE_TABLE_SIZE];
} ptable;

typedef struct pdirectory_s {
	pd_entry tables[PAGE_DIRECTORY_SIZE];
	ptable *tables_virt[PAGE_DIRECTORY_SIZE];
	physical_addr directory_ptr;
} pdirectory;

void vmm_initialize();
void vmm_kbrk(void* current_end,size_t size);
void vmm_alloc_area(void* virt_s,void *virt_e,char writable,char user);
#endif